import http from "@/api";

/**
 * 根据系统配置类型获取系统配置
 */
export const sysConfigsApi = (type: string) => {
    return http.get(`/sys/configs/${type}`);
}

/**
 * 按类型分组查询系统配置
 * @param params
 */
export const sysConfigsByTypeApi = (params: object) => {
    return http.get('/sys/config/list/group/type', params);
}

/**
 * 保存系统配置
 * @param params
 */
export const saveSysConfigsApi = (params: object) => {
    return http.post("/sys/configs/save", params);
}

/**
 * 获取系统配置类型列表
 */
export const sysConfigTypesApi = () => {
    return http.get("/sys/config/types");
}

/**
 * 获取系统配置值类型列表
 */
export const sysConfigFieldTypesApi = () => {
    return http.get("/sys/config/field/types");
}

/**
 * 系统配置分页列表
 * @param params
 */
export const sysConfigPageListApi = (params: object) => {
    return http.get(`/sys/config/paging`, params);
};

/**
 * 新增系统配置
 * @param params
 */
export const addSysConfigApi = (params: object) => {
    return http.post(`/sys/config/add`, params);
};

/**
 * 编辑系统配置
 * @param params
 */
export const editSysConfigApi = (params: any) => {
    return http.put(`/sys/config/edit/${params.id}`, params);
};

/**
 * 切换系统配置状态
 * @param id
 */
export const changeStatusApi = (id: number) => {
    return http.put(`/sys/config/change_status/${id}`);
};

/**
 * 修改系统配置排序
 * @param params
 */
export const changeSortApi = (params: object) => {
    return http.post(`/sys/config/changeSort`, params);
};

/**
 * 删除系统配置
 * @param id
 */
export const deleteSysConfigByIdApi = (id: number) => {
    return http.delete(`/sys/config/delete/${id}`);
};

/**
 * 批量删除
 * @param params
 */
export const deleteSysConfigApi = (params: object) => {
    return http.post(`/sys/config/delete`, params);
};
